home *** CD-ROM | disk | FTP | other *** search
- Notes on the Demo Scripts:
-
- To run the demo, run the Postmaster if you are not running it already, and
- create a demo database using the createdb (unix) command. After this,
- cd into ~postgres/demo and run the Monitor. The '*' indicates the Monitor
- prompt.
-
-
- Note: An alternative that avoids all of this typing is to run the wholedemo.sh
- script. It creates a database demo and runs each of the demo queries
- automatically. The queries run are echoed so you can see exactly what the
- demo does by simply examining the output that the script produces.
-
- 1. Populate the demo database. You do this by doing
-
- * \i set-up-1.pq
- <you will see lots of stuff>
- (On certain machines, running this may take awhile - be patient)
-
- After this, run scripts 1 through 22 in the following manner
-
- * \i script-nn
-
- where nn is from 1 to 25.
-
- Script 1 shows the initial state of the "city" and "emp" tables.
-
- Script 2 runs a simple query using a join.
-
- Script 3 shows the Postgres feature of user-defined functions at work. The
- "boxarea" function returns the area of the city by using its "location"
- parameter. The source for this function is in ~postgres/demo/boxarea.c, and
- this function is defined in set-up-1.pq.
-
- Script 4 shows an inheritable or tuple function at work. The source for
- "overpaid" is in ~postgres/demo/overpaid.c. Writing an inheritable function
- is described in the tutorial "Writing a Function of a Tuple".
-
- Script 5 shows an array being used in a query. In this case, the array is the
- fixed-length array "budget", which has four elements. Postgres supports both
- fixed-length and variable-length arrays of fixed-size elements. Postgres
- arrays are discussed in the tutorial "Defining an Array Type".
-
- Script 6 shows an operator working on the "location" field. Users can define
- unary or binary operators which operate on any Postgres type.
-
- Script 7 shows an operator being defined. The C function pt_in_circle()
- evaluates the arguments of the operator and returns the result - the source
- to this function is in ~postgres/demo/circle.c. This C function and the
- circle type (as well as its in/out functions) are defined by queries in
- set-up-1.pq. User defined types, operators, and functions are described in
- detail in the tutorial "Defining User Defined Types, Operators, and Functions".
-
- Script 8 shows the operator in Script 7 being used in a query.
-
- Script 9, 10, and 11 show Postgres time-based queries at work. The query in
- script 9 shows Sam's current salary.
-
- Script 10 gives Sam a raise.
-
- Script 11 shows Sam's salary history, using the special Postgres time
- attributes "tmin", and "tmax".
-
- Script 12 shows a join of the student and emp tables.
-
- Script 13 shows a similar appearing query, but this time inheritance is used
- by the "*" notation.
-
- Script 14 shows the current state of the emp table.
-
- Script 15 defines a tuple level rule. This rule forces Bill's salary to be
- equal to Sharon's salary.
-
- Script 16 defines another tuple level rule. This rule forces Sam's salary
- to be twice Bill's salary.
-
- Script 17 gives Sharon a raise, causing both rules to fire.
-
- Script 18 shows that both rules did fire by showing the new state of the emp
- table.
-
- Script 19 deletes these rules.
-
- Script 20 defines a backward-chaining tuple rule. This rule retrieves twice
- Bill's salary whenever an attempt is made to fetch Sam's salary.
-
- Script 21 defines another backward-chaining tuple rule. This rule retrieves
- thrice Sharon's salary whenever a fetch is made to Bill's salary.
-
- Script 22 shows these rules in action, by doing a retrieve on the emp table.
-
- Script 23 demonstrates the average aggregate on the emp table.
-
- Script 24 demonstrates how to create an aggregate named "bletch"
-
- Script 25 simple removes the aggregate named "bletch"
-
- The Postgres rule system is described in the paper "On Rules, Caching,
- Procedures, and Views", which is included in this distribution in the
- ./doc/papers directory.
-